﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dukou.Dao.Impl;
using Dukou.Security.Domain;
using NHibernate;

namespace Dukou.Security.Dao.Impl
{
    public class RoleDao : NHibernateDao<Role, Int64>, IRoleDao
    {
        public Role FindByName(string name)
        {
            return this.HibernateTemplate.Execute<Role>(delegate(ISession session)
            {
                var roles = session.CreateQuery("from Role r where r.Name = ?")
                    .SetParameter(0, name)
                    .List<Role>();
                return roles.FirstOrDefault();
            });
        }
    }
}
